package com.qq.weixin.constant;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

import com.hxexp.weixin.constant.DeployEnvironment;

/**
 * 微信开发常量类
 * @author li.jiang
 *
 */
public final class AppDevConstant {
    /**
     * 华夏快线服务号开发需要的常量
     *
     * @author li.jiang
     *
     */
    public static final class HxExp {
        /**
         * 用于生成签名的令牌
         */
        public static final String TOKEN = "4860962c715a757674c1c28b6ab9223c";
        /**
         * 消息体加解密密钥
         */
        public static final String ENCODING_AESKEY = "dc04e9f643b3a675352cccf6743cbf1d2ddfadfa1o8";
        /**
         * 应用ID
         */
        public static final String APPID = "wx09a52b00c181c032";
        /**
         * 应用密钥
         */
        public static final String APPSECRET = "34c7fb78c0916ed0917fce42e5b98e89";
        /**
         * 微信支付API密钥
         */
        public static final String WXPAY_API_SECRETKEY = "58e23e2783b4f684a54004e42111f512"; // NOSONAR
        /**
         * 商户ID
         */
        public static final String MCHID = "1236104802";

        private HxExp() {
        }
    }

    /**
     * 华夏快线测试服务号开发需要的常量
     *
     * @author li.jiang
     *
     */
    public static final class HxExpTest {
        /**
         * 用于生成签名的令牌
         */
        public static final String TOKEN = "d1748cbff21b7e8b4fd2b16dc87bac0b";
        /**
         * 消息体加解密密钥
         */
        public static final String ENCODING_AESKEY = "znJ0fee7MuPBjTQExVt2G4IloRnD9C6NykbjsIysrGP";
        /**
         * 应用ID
         */
        public static final String APPID = "wx3f9d504e31fe8d86";
        /**
         * 应用密钥
         */
        public static final String APPSECRET = "3709acc16d2b31fd3e723396677666db";
        /**
         * 微信支付API密钥
         */
        public static final String WXPAY_API_SECRETKEY = "58e23e2783b4f684a54004e42111f512"; // NOSONAR
        /**
         * 商户ID
         */
        public static final String MCHID = "1284529101";

        private HxExpTest() {
        }
    }

    /**
     * 华夏快线西安公司服务号需要的常量
     *
     * @author li.jiang
     *
     */
    public static final class HxExpXA {
        /**
         * 应用ID
         */
        public static final String APPID = "wx2122a018de58c19a";
        /**
         * 应用密钥
         */
        public static final String APPSECRET = "e0be29d9bfa7fa6ca598cce7fd53b031";
        /**
         * 微信支付API密钥
         */
        public static final String WXPAY_API_SECRETKEY = "58e23e2783b4f684a54004e42111f512"; // NOSONAR
        /**
         * 商户ID
         */
        public static final String MCHID = "1367033202";
    }

    /**
     * openid密钥，加密解密openid时使用
     */
    public static final String OPENIDSECRET = "c8a9229820ffa315bc6a17a9e43d01a9";

    private static final Map<String, String> APPID_MAP = Collections.synchronizedMap(new LinkedHashMap<String, String>(3));
    private static final Map<String, String> APPSECRET_MAP = Collections.synchronizedMap(new LinkedHashMap<String, String>(3));
    private static final Map<String, String> WXPAY_API_SECRETKEY_MAP = Collections.synchronizedMap(new LinkedHashMap<String, String>(3));

    static {
        APPID_MAP.put(DeployEnvironment.TEST, HxExpTest.APPID);
        APPID_MAP.put(DeployEnvironment.PRODUCT, HxExp.APPID);
        APPID_MAP.put(DeployEnvironment.PRODUCT_XA, HxExpXA.APPID);

        APPSECRET_MAP.put(DeployEnvironment.TEST, HxExpTest.APPSECRET);
        APPSECRET_MAP.put(DeployEnvironment.PRODUCT, HxExp.APPSECRET);
        APPSECRET_MAP.put(DeployEnvironment.PRODUCT_XA, HxExpXA.APPSECRET);

        WXPAY_API_SECRETKEY_MAP.put(DeployEnvironment.TEST, HxExpTest.WXPAY_API_SECRETKEY);
        WXPAY_API_SECRETKEY_MAP.put(DeployEnvironment.PRODUCT, HxExp.WXPAY_API_SECRETKEY);
        WXPAY_API_SECRETKEY_MAP.put(DeployEnvironment.PRODUCT_XA, HxExpXA.WXPAY_API_SECRETKEY);
    }

    private AppDevConstant() {
    }

    /**
     * 获取部署环境对应的应用ID
     *
     * @param deployEnvironment
     *            部署环境标识
     * @return
     */
    public static String getAppId(String deployEnvironment) {
        return APPID_MAP.get(deployEnvironment);
    }

    /**
     * 获取部署环境对应的应用密钥
     *
     * @param deployEnvironment
     *            部署环境标识
     * @return
     */
    public static String getAppSecret(String deployEnvironment) {
        return APPSECRET_MAP.get(deployEnvironment);
    }

    /**
     * 获取部署环境对应的微信支付API密钥
     *
     * @param deployEnvironment
     *            部署环境标识
     * @return
     */
    public static String getPaySecretKey(String deployEnvironment) {
        return WXPAY_API_SECRETKEY_MAP.get(deployEnvironment);
    }
}
